package com.example.demo.study.objectpolymorphic;

public class AnimalTest2 {
    public static void main(String[] args) {
        useAnimal(new Dog());
        useAnimal(new Cat());
        useAnimal(new Pig());
    }
    // 方法重载 overLoad -- 名字相同 参数类型不同
    public static void useAnimal(Dog dog){
        dog.eat();
        dog.lookHome();
    }
    public static void useAnimal(Cat cat){
        cat.eat();
        cat.catchMouse();
    }
    public static void useAnimal(Pig pig){
        pig.eat();
        pig.sleep();
    }
}
